<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>属性描述符</title>
</head>
<body>
<script>

    /*
    * 使用属性描述符可以创建常量
    * */
    let user = {
        username: 'john'
    }

    console.dir(Object.getOwnPropertyDescriptor(user, 'username'))

    Object.defineProperty(user, 'age', {
        value: 20
    })

    /*创建常量*/
    Object.defineProperty(user, 'num', {
        writable: false,
        value: 100
    })

    // console.log(user.age)
    user.num = 200
    console.log(user.num)
</script>
</body>
</html>